package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

import calendar.Event;

/**
 * Klasse repräsentiert ein Panel in der Monatsansicht
 * 
 * @author Michi
 * 
 */
public class DayPanel extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 9025734459542926903L;
	private JTextField termin1;
	private JTextField termin2;
	private JTextField moreField;
	private JTextField nameOfDayField;
	private Date date;
	private JButton hinzufuegenButton;
	private LinkedList<Event> eventList = new LinkedList<Event>();
	private Boolean colored;
	private JPanel northPanel;
	private JPanel nameOfDayPanel;
	private JPanel buttonPanel;
	private JPanel terminPanel;
	private boolean isSelected = false;
	// muss generisch bleiben um verschiedene Datentypen speichern zu können!!
	@SuppressWarnings("rawtypes")
	private List allCalendarItems;

	// Getter & Setter

	@SuppressWarnings("rawtypes")
	public List getAllCalendarItems() {
		return allCalendarItems;
	}

	@SuppressWarnings("rawtypes")
	public void setAllCalendarItems(List allCalendarItems) {
		this.allCalendarItems = allCalendarItems;
	}

	public boolean isSelected() {
		return isSelected;
	}

	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}

	public JPanel getNorthPanel() {
		return northPanel;
	}

	public void setNorthPanel(JPanel northPanel) {
		this.northPanel = northPanel;
	}

	public JPanel getNameOfDayPanel() {
		return nameOfDayPanel;
	}

	public void setNameOfDayPanel(JPanel nameOfDayPanel) {
		this.nameOfDayPanel = nameOfDayPanel;
	}

	public JPanel getButtonPanel() {
		return buttonPanel;
	}

	public void setButtonPanel(JPanel buttonPanel) {
		this.buttonPanel = buttonPanel;
	}

	public JPanel getTerminPanel() {
		return terminPanel;
	}

	public void setTerminPanel(JPanel terminPanel) {
		this.terminPanel = terminPanel;
	}

	public void addEvent(Event e) {
		eventList.add(e);
	}

	public void removeEvent(Event e) {
		eventList.remove(e);
	}

	public Boolean getColored() {
		return colored;
	}

	public void setColored(Boolean colored) {
		this.colored = colored;
	}

	public LinkedList<Event> getEventList() {
		return eventList;
	}

	public void setEventList(LinkedList<Event> eventList) {
		this.eventList = eventList;
	}

	public JButton getHinzufuegenButton() {
		return hinzufuegenButton;
	}

	public void setHinzufuegenButton(JButton hinzufuegenButton) {
		this.hinzufuegenButton = hinzufuegenButton;
	}

	public JTextField getTermin1() {
		return termin1;
	}

	public void setTermin1(JTextField termin1) {
		this.termin1 = termin1;
		termin1.setCaretPosition(0);
	}

	public JTextField getTermin2() {
		return termin2;
	}

	public void setTermin2(JTextField termin2) {
		this.termin2 = termin2;
		termin2.setCaretPosition(0);
	}

	public JTextField getMoreField() {
		return moreField;
	}

	public void setMoreField(JTextField moreField) {
		this.moreField = moreField;

	}

	public JTextField getNameOfDayField() {
		return nameOfDayField;
	}

	public void setNameOfDayField(JTextField nameOfDayField) {
		this.nameOfDayField = nameOfDayField;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * Create the panel.
	 */
	@SuppressWarnings("rawtypes")
	public DayPanel() {

		// Initialisierung
		allCalendarItems = new ArrayList();

		setBackground(Color.WHITE);
		setMinimumSize(new Dimension(130, 100));
		setMaximumSize(new Dimension(130, 100));
		setSize(new Dimension(130, 100));
		setPreferredSize(new Dimension(130, 88));
		setLayout(new BorderLayout(0, 0));

		northPanel = new JPanel();
		northPanel.setBackground(Color.WHITE);
		northPanel.setSize(new Dimension(130, 25));
		northPanel.setMinimumSize(new Dimension(130, 25));
		northPanel.setMaximumSize(new Dimension(130, 25));
		northPanel.setPreferredSize(new Dimension(130, 25));
		add(northPanel, BorderLayout.NORTH);

		nameOfDayPanel = new JPanel();
		nameOfDayPanel.setBorder(null);
		nameOfDayPanel.setBackground(Color.WHITE);
		nameOfDayPanel.setOpaque(false);
		nameOfDayPanel.setMaximumSize(new Dimension(100, 20));
		nameOfDayPanel.setMinimumSize(new Dimension(100, 20));
		nameOfDayPanel.setSize(new Dimension(100, 20));
		nameOfDayPanel.setPreferredSize(new Dimension(100, 20));
		northPanel.add(nameOfDayPanel);

		nameOfDayField = new JTextField();
		nameOfDayField.setBorder(null);
		nameOfDayField.setFont(new Font("Lucida Grande", Font.ITALIC, 9));
		nameOfDayField.setBackground(Color.WHITE);
		nameOfDayField.setSize(new Dimension(100, 15));
		nameOfDayField.setMinimumSize(new Dimension(100, 15));
		nameOfDayField.setMaximumSize(new Dimension(100, 15));
		nameOfDayField.setEnabled(false);
		nameOfDayField.setEditable(false);
		nameOfDayField.setDisabledTextColor(Color.BLACK);
		nameOfDayField.setPreferredSize(new Dimension(115, 15));
		nameOfDayPanel.add(nameOfDayField);
		nameOfDayField.setColumns(12);

		buttonPanel = new JPanel();
		buttonPanel.setBackground(Color.WHITE);
		buttonPanel.setSize(new Dimension(20, 20));
		buttonPanel.setMaximumSize(new Dimension(20, 20));
		buttonPanel.setMinimumSize(new Dimension(20, 20));
		buttonPanel.setPreferredSize(new Dimension(20, 20));
		northPanel.add(buttonPanel);

		hinzufuegenButton = new JButton("+");
		hinzufuegenButton.setMaximumSize(new Dimension(18, 18));
		hinzufuegenButton.setMinimumSize(new Dimension(18, 18));
		hinzufuegenButton.setSize(new Dimension(18, 18));
		hinzufuegenButton.setMargin(new Insets(0, 0, 0, 0));
		hinzufuegenButton.setPreferredSize(new Dimension(20, 15));
		buttonPanel.add(hinzufuegenButton);

		terminPanel = new JPanel();
		terminPanel.setBackground(Color.WHITE);
		terminPanel.setSize(new Dimension(130, 75));
		terminPanel.setPreferredSize(new Dimension(130, 64));
		terminPanel.setMinimumSize(new Dimension(130, 75));
		terminPanel.setMaximumSize(new Dimension(130, 75));
		add(terminPanel, BorderLayout.CENTER);

		termin1 = new JTextField();
		termin1.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
		termin1.setBorder(null);
		termin1.setDisabledTextColor(Color.BLACK);
		termin1.setEnabled(false);
		termin1.setEditable(false);
		termin1.setBackground(Color.WHITE);
		termin1.setPreferredSize(new Dimension(130, 15));
		terminPanel.add(termin1);
		termin1.setColumns(14);

		termin2 = new JTextField();
		termin2.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
		termin2.setBorder(null);
		termin2.setDisabledTextColor(Color.BLACK);
		termin2.setEnabled(false);
		termin2.setEditable(false);
		termin2.setBackground(Color.WHITE);
		termin2.setPreferredSize(new Dimension(130, 15));
		terminPanel.add(termin2);
		termin2.setColumns(14);

		moreField = new JTextField();
		moreField.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
		moreField.setBorder(null);
		moreField.setVisible(false);
		moreField.setDisabledTextColor(Color.BLACK);
		moreField.setEnabled(false);
		moreField.setEditable(false);
		moreField.setBackground(Color.WHITE);
		moreField.setPreferredSize(new Dimension(130, 15));
		terminPanel.add(moreField);
		moreField.setColumns(14);

	}

}
